cmake_minimum_required(VERSION 3.5)
project(golfdds)

option(BUILD_STATIC "build static library" OFF)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")

SET(CMAKE_CXX_FLAGS "-std=c++14 -g")
SET(CMAKE_C_FLAGS " -g")
#add_subdirectory(ring_queue)
set(GOLFDDSSRC
	src/golfdds_shm.c
	src/golfdds.c
	)
set(PUBLISHER 
	example/publisher.c
	)
set(SUBSCRIBER 
	example/subscriber.c
	)
#set(CORE 
#		example/core.c
#		)

add_subdirectory(ring_queue)


if(BUILD_STATIC)
	add_library(golfdds STATIC ${GOLFDDSSRC})
	target_link_libraries(golfdds ring_queue)
else()
	add_library(golfdds SHARED ${GOLFDDSSRC})
endif()
target_include_directories(golfdds PUBLIC 
	./include
	${CMAKE_CURRENT_SOURCE_DIR}/ring_queue/include
	)

#add_executable(core ${CORE}) #因为可以查询到绑定127.0.0.1的所有端口，所以节点程序可以自己去查询，并不需要这个core程序
add_executable(publisher ${PUBLISHER})
add_executable(subscriber ${SUBSCRIBER})

#target_link_libraries(core golfdds ring_queue pthread)
target_link_libraries(publisher golfdds ring_queue pthread)
target_link_libraries(subscriber golfdds ring_queue pthread)
